how to check if a record exists in a mysql database using java